using System.ComponentModel.DataAnnotations;
using System.Data.Entity.ModelConfiguration;

namespace G15_Agent.Models.Mapping
{
    public class TheTinDungMap : EntityTypeConfiguration<TheTinDung>
    {
        public TheTinDungMap()
        {
            // Primary Key
            this.HasKey(t => t.MaThe);

            // Properties
            this.Property(t => t.MaThe)
                .IsRequired()
                .HasMaxLength(15);

            this.Property(t => t.MaNguoiDung)
                .HasMaxLength(15);

            // Table & Column Mappings
            this.ToTable("TheTinDung");
            this.Property(t => t.MaThe).HasColumnName("MaThe");
            this.Property(t => t.MaNguoiDung).HasColumnName("MaNguoiDung");

            // Relationships
            this.HasOptional(t => t.NguoiDung)
                .WithMany(t => t.TheTinDungs)
                .HasForeignKey(d => d.MaNguoiDung);

        }
    }
}
